﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Persistence
{
    public class Singleton<T>
    {
        private Singleton()
        { }
        public static T Instance
        {
            get { return SingletonCreator.instance; }
        }
        class SingletonCreator
        {
            internal static readonly T instance = (T)Activator.
                CreateInstance(
                                System.Type.GetType(
                                System.Text.RegularExpressions.Regex.Replace(typeof(T).ToString(),@"([a-zA-Z0-9]+)\.I([a-zA-Z0-9]+)\.I([a-zA-Z0-9]+)","$1.$2.$3")
                                )
                                ,true
                );
               
        }


    }

}
